package com.crp.unitalinforbaseplat.app;

import com.github.pagehelper.PageHelper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.Properties;

@SpringBootApplication //开启初始化配置，必须有
@Controller
@ComponentScan(basePackages = "com.crp.unitalinforbaseplat") //扫描注解
//@EnableAutoConfiguration(exclude = {MultipartAutoConfiguration.class})
@MapperScan({"com.crp.unitalinforbaseplat.app.unitalinforbaseplat.dao","com.crp.unitalinforbaseplat.app.sys.dao"})
@EnableTransactionManagement //开启事务
@EnableCaching //开启缓存
@EnableScheduling
public class UnitalinforbaseplatApplication {

    public static void main(String[] args) {
        SpringApplication.run(UnitalinforbaseplatApplication.class, args);
    }
    //配置mybatis的分页插件pageHelper
    @Bean
    public PageHelper pageHelper(){
        PageHelper pageHelper = new PageHelper();
        Properties properties = new Properties();
        properties.setProperty("offsetAsPageNum","true");
        properties.setProperty("rowBoundsWithCount","true");
        properties.setProperty("reasonable","true");
        properties.setProperty("dialect","mysql");    //配置mysql数据库的方言
        pageHelper.setProperties(properties);
        return pageHelper;
    }
}
